﻿#if UNITY_EDITOR
using System;
using System.Runtime.CompilerServices;

/// <summary>
/// ESF_BuildXmlAsset_CacheXmlCatalog静态变量
/// </summary>
public static class ESF_BuildXmlAsset_CacheXmlCatalog_GlobalVariable
{
    /// <summary>
    /// 实例类型名称
    /// </summary>
    public const string cInstanceTypeName = "ESF_BuildXmlAsset_CacheXmlCatalog`1";
}
/// <summary>
/// 缓存Xml目录
/// </summary>
public class ESF_BuildXmlAsset_CacheXmlCatalog<X> : ESF_BuildXmlAsset<X>
    where X : AbsESF_Xml, new()
{   
    /// <summary>
    /// 说明
    /// </summary>
    string desc = string.Empty;
    /// <summary>
    /// 目录
    /// </summary>
    public ESF_enCacheXmlCatalog catalog { get; private set; }
    /// <summary>
    /// 缓存Xml目录
    /// </summary>
    /// <param name="_catalog">目录</param>
    /// <param name="_fileName">文件名称</param>
    /// <param name="_directoryRelativeCallerFilePath">相对于调用文件目录</param>
    /// <param name="_sourceFilePath">源文件路径</param>
    public ESF_BuildXmlAsset_CacheXmlCatalog(ESF_enCacheXmlCatalog _catalog, string _fileName, string _directoryRelativeCallerFilePath = "", [CallerFilePath] string _sourceFilePath = "")
        : base(string.IsNullOrEmpty(_fileName) ? $"[{_catalog}]_{typeof(X).Name}" : _fileName, _directoryRelativeCallerFilePath, _sourceFilePath)
    {

        catalog = _catalog;
        ESF_AliasTooltipAttribute attr = catalog.ESF_FirstAttribute<ESF_AliasTooltipAttribute>();
        if (attr != null)
        {
            desc = attr.alias;
        }
    }

    /// <summary>
    /// 获得文件描述
    /// </summary>
    /// <returns>文件描述</returns>
    protected override string OnGetFileDesc() { return desc; }

    /// <summary>
    /// 绘制选择枚举过滤布局
    /// </summary>
    /// <returns>过滤布局</returns>
    protected override Type[] OnDrawSelectFilterEnums() {
        Type[] types = null;
        ESF_GUISelectFilterEnumAttribute ettr = catalog.ESF_FirstAttribute<ESF_GUISelectFilterEnumAttribute>();
        if (ettr != null)
        {
            types = ettr.types;
        }
        return types;
    }
}
#endif
